const db = uniCloud.database()
exports.main = async (event) => {
  try {
    // 基本参数校验
    if (!event.mobile) {
      return { code: 400, message: '缺少手机号参数' }
    }

    // 直接查询数据库
    const res = await db.collection('topics')
      .where({
        mobile: event.mobile,
        type: 'reject'
      })
      .orderBy('review_time', 'desc')
      .get()

    return {
      code: 200,
      data: res.data,
      message: 'success'
    }

  } catch (err) {
    console.error('云函数错误:', err)
    return {
      code: 500,
      message: '服务器错误',
      data: null
    }
  }
}